package com.park.user.controller.order;

import com.github.pagehelper.PageInfo;
import com.park.controller.BaseController;
import com.park.entity.order.MerOrderStartEndDto;
import com.park.entity.page.PageInfoParm;
import com.park.entity.user.UserLoginVo;
import com.park.response.Result;
import com.park.user.anno.UserToken;
import com.park.user.service.order.ParkOrderInfoService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.Map;

/**
 * @author Administrator
 * @title: OrderController
 * @projectName park
 * @description: 用户订单
 * @date 2020/5/211:43
 */
@RestController
@RequestMapping(value = "/wx/order")
public class OrderController extends BaseController {

    @Autowired
    private ParkOrderInfoService parkOrderInfoService;

    /**
 　　* @description:  查询我的订单
 　　* @param [userLoginVo]
 　　* @return {@link Result}
 　　* @throws
 　　* @author ZhangHaiWen
 　　* @version 2.0
 　　* @date 2020/5/4 12:08
 　　*/
    @UserToken
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public Result myOrderList(@RequestBody PageInfoParm<UserLoginVo> pageInfoParm){
        Integer userId = getUserId();
        PageInfo coachInvitationVoList = parkOrderInfoService.myOrderList(pageInfoParm,userId);
        return SUCCESS(coachInvitationVoList);
    }

    /**
     　　* @description:
     　　* @param [] 用户支付订单
     　　* @return {@link Result}
     　　* @throws
     　　* @author ZhangHaiWen
     　　* @version 2.0
     　　* @date 2020/5/6 14:43
     　　*/
    @UserToken
    @RequestMapping(value = "/pay",method = RequestMethod.POST)
    public Result pay(@RequestBody MerOrderStartEndDto orderStartEndDto) {
        Integer userId = getUserId();
        String ipAddr = getIpAddr();
        Map<String, String> pay = parkOrderInfoService.pay(userId, orderStartEndDto,ipAddr);
        return SUCCESS(pay);
    }



}
